<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 创建了一个用于存储10个字节的内存空间
      const bf = new ArrayBuffer(10);

      // slice()
      /*  const bf2 = bf.slice(3, 5);
      console.log(bf, bf2); */

      // DataView
      /* const view = new DataView(bf, 3, 4);
      console.log(view, view.buffer.byteLength === view.byteLength);
      view.setInt8(1, 3);
      console.log(view, view.getInt8(1)); */

      // 类型化数组
      const arr1 = new Int8Array(bf);
      const arr2 = new Int16Array(bf);
      console.log(arr1 === arr2);
      console.log(arr1, arr1.length === arr2.buffer);
      arr1[0] = 10;
    </script>
  </body>
</html>
